#PURPOSE: This program finds the maximum number of a set of data items
#         
#
#INPUT: none
#
#OUTPUT: returns a status code, That can be view by typint  
#
#        echo $?
#        after running the program
#        
#VARIABLES: The registers hava the following uses:
#        %edi: holds the index of the data item being examined 
#        %ebx: largest data item found
#        %eax: current data item
#
# The following memory location are used:
#   data_items: contains the item data. a 0 is used to teminate the data
#             

.section .data
data_items: #no bigger then 255
.long 3, 67, 34, 222, 128, 77, 86, 93, 255, 0

.section .text

.global _start

_start:
 movl $0, %edi
 movl data_items(,%edi,4), %eax
 movl %eax, %ebx

start_loop:
 cmpl $0, %eax
 je loop_exit
 incl %edi
 movl data_items(,%edi,4), %eax
 cmpl %ebx, %eax
 jle start_loop # %eax <= %ebx?
 movl %eax, %ebx
 jmp start_loop


loop_exit:
 movl $1, %eax
 int $0x80
